<!DOCTYPE html>
<html lang="">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <link rel="icon" href="<%= BASE_URL %>favicon.ico">
  <title></title>
  <script>
    const domains = ['12222123.com']; //域名列表 
    const retry = {};
    window.addEventListener('error', (e) => {
      if (e.target.tagName !== "SCRIPT" || e instanceof ErrorEvent) return;
      const url = new URL(e.target.src);
      const key = url.pathname;
      if (!(key in retry)) {
        retry[key] = 0;
      }
      const index = retry[key];
      if (index >= domains.length) {
        return;
      }
      const domain = domains[index];
      url.host = domain;
      //重新请求
      //使用document.write阻塞浏览器渲染
      document.write('\<script src=' + url.toString() + '>\<\/script>');
      retry[key]++;
    }, true)
  </script>
</head>

<body>
  <noscript>
    <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
        Please enable it to continue.</strong>
  </noscript>
  <div id="app">
    <div class="loading">
      <img src="./img/loading.gif" alt="" class="loading">
    </div>
  </div>
  <style>
    .loading {
      position: fixed;
      top: 50%;
      left: 50%;
      height: 200px;
      width: 200px;
      transform: translate(-50%, -50%);
    }
  </style>
  <!-- ref cdn -->
  <% if(NODE_ENV==="production" ) { %>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.12/vue.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/vuex/3.5.1/vuex.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue-router/3.4.7/vue-router.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.0/axios.min.js"></script>
    <% } %>
      <!-- built files will be auto injected -->
      <!-- script加载失败抛出错误无法进行冒泡，需要在捕获阶段进行注册事件 -->
</body>

</html>